package Month07.day31;

import java.io.File;

public class test3 {
    public static void main(String[] args) {
        File file = new File("D:\\Idea-Project\\basic\\yuankang-edu-info-manager");
//        long length = file.length();
//        System.out.println(length);//输出文件夹都是4096
        long sum = getSum(file);
        System.out.println(sum);
    }

    private static long getSum(File file) {
        File[] files = file.listFiles();
        long count = 0;
//        if (files != null) {
            for (File path : files) {
                if (path.isFile()) {
                    count += path.length();
                } else if (path.isDirectory()) {
                    getSum(path);
                }
            }
//        }
        return count;
    }
}
